﻿@model AuctionControllerModel.Index
<div>
    <div class="ui-box  ui-box-alpha">
        <div class="ui-box-head">
            <div class="ui-box-head-border">
                <div class="ui-box-head-title">
                    拍品管理
                </div>
                <span class="ui-box-head-text">拍品列表</span>
            </div>
        </div>
        <div class="ui-box-container">
            <div class="ui-box-content">
                @using (Html.BeginForm("index", "auction", FormMethod.Get, new { @class = "form-horizontal", role = "form" }))
                {
                    <div class="form-group">
                        <label for="keyword" class="col-md-2 control-label">
                            拍品Id/名称</label>
                        <div class="col-md-2">
                            <input type="text" id="keyword" name="keyword" class="form-control" maxlength="30"   value="@(Model.Keyword)" />
                        </div>
                        <label for="itemId" class="col-md-2 control-label">
                            商品Id</label>
                        <div class="col-md-2">
                            <input type="text" id="itemId" name="itemId" class="form-control" maxlength="20"  value="@(Model.ItemId)" />
                        </div>
                        <label for="onlineDate" class="col-md-2 control-label">
                            开拍日期</label>
                        <div class="col-md-2">
                            <input type="text" id="onlineDate" name="onlineDate" class="form-control datepicker" maxlength="10"   value="@(Model.OnlineDate.ToString(string.Empty))" data-date-format="yyyy-mm-dd"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="user" class="col-md-2 control-label">
                            用户Id/名称</label>
                        <div class="col-md-2">
                            <input type="text" id="user" name="user" class="form-control" maxlength="50"   value="@(Model.User)" />
                        </div>
                        <label for="finishedDate" class="col-md-2 control-label">
                            结束日期</label>
                        <div class="col-md-2">
                            <input type="text" id="finishedDate" name="finishedDate" class="form-control datepicker" maxlength="10"   value="@(Model.FinishedDate.ToString(string.Empty))" data-date-format="yyyy-mm-dd"/>
                        </div>
                        <label for="status" class="col-md-2 control-label">
                            状 态</label>
                        <div class="col-md-2">
                            <select id="status" name="status" class="form-control">
                                <option value="" @(!Model.Status.HasValue ? "selected=selected" : string.Empty)>所有</option>
                                <option value="0" @(Model.Status.HasValue && Model.Status.Value == AuctionStatus.Normal ? "selected=selected" : string.Empty)>
                                    正常</option>
                                <option value="1" @(Model.Status.HasValue && Model.Status.Value == AuctionStatus.Paused ? "selected=selected" : string.Empty)>
                                    已暂停</option>
                                <option value="2" @(Model.Status.HasValue && Model.Status.Value == AuctionStatus.Finished ? "selected=selected" : string.Empty)>
                                    已结束</option>
                                <option value="3" @(Model.Status.HasValue && Model.Status.Value == AuctionStatus.Deleted ? "selected=selected" : string.Empty)>
                                    已删除</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-offset-1 col-md-9">
                            <div class="checkbox">
                                <ul class="list-inline">
                                    <li style="margin-left: 0px; margin-right: 20px;">
                                        <label>
                                            <input type="checkbox" name="reservation" value="@(Model.Reservation.HasValue && Model.Reservation.Value ? "true" : "false")" @(Model.Reservation.HasValue && Model.Reservation.Value ? "checked=checked" : string.Empty) onclick="if (this.checked==true){this.value=true;}else{this.value=false;}" />
                                            <span>预约竞购</span>
                                        </label>
                                    </li>
                                    <li style="margin-left: 0px; margin-right: 20px;">
                                        <label>
                                            <input type="checkbox" name="diffBuy" value="@(Model.DiffBuy.HasValue && Model.DiffBuy.Value ? "true" : "false")" @(Model.DiffBuy.HasValue && Model.DiffBuy.Value ? "checked=checked" : string.Empty) onclick="if (this.checked==true){this.value=true;}else{this.value=false;}" />
                                            <span>充许补差购买</span>
                                        </label>
                                    </li>
                                    <li style="margin-left: 0px; margin-right: 20px;">
                                        <label>
                                            <input type="checkbox" name="freeBid" value="@(Model.FreeBid.HasValue && Model.FreeBid.Value ? "true" : "false")" @(Model.FreeBid.HasValue && Model.FreeBid.Value ? "checked=checked" : string.Empty) onclick="if (this.checked==true){this.value=true;}else{this.value=false;}" />
                                            <span>充许使用免费拍币</span>
                                        </label>
                                    </li>
                                    <li style="margin-left: 0px; margin-right: 20px;">
                                        <label>
                                            <input type="checkbox" name="dynamic" value="@(Model.Dynamic.HasValue && Model.Dynamic.Value ? "true" : "false")" @(Model.Dynamic.HasValue && Model.Dynamic.Value ? "checked=checked" : string.Empty) onclick="if (this.checked==true){this.value=true;}else{this.value=false;}" />
                                            <span>动态调整重置秒数</span>
                                        </label>
                                    </li>
                                    <li style="margin-left: 0px; margin-right: 20px;">
                                        <label>
                                            <input type="checkbox" name="isZero" value="@(Model.IsZero.HasValue && Model.IsZero.Value ? "true" : "false")" @(Model.IsZero.HasValue && Model.IsZero.Value ? "checked=checked" : string.Empty) onclick="if (this.checked==true){this.value=true;}else{this.value=false;}" />
                                            <span>0元竞购</span>
                                        </label>
                                    </li>
                                    <li style="margin-left: 0px; margin-right: 20px;">
                                        <label>
                                            <input type="checkbox" name="isAuto" value="@(Model.IsAuto.HasValue && Model.IsAuto.Value ? "true" : "false")" @(Model.IsAuto.HasValue && Model.IsAuto.Value ? "checked=checked" : string.Empty) onclick="if (this.checked==true){this.value=true;}else{this.value=false;}" />
                                            <span>自动补货</span>
                                        </label>
                                    </li>
                                </ul>
                            </div>
                        </div>
                        <div class="col-md-2">
                            <button type="submit" class="btn btn-default">
                                搜 索</button>
                        </div>
                    </div>
                }
            </div>
        </div>
        <div class="ui-box-container-noborder">
            <div class="ui-box-content">
            </div>
        </div>
        <div class="ui-box-container-noborder">
            <table class="ui-table ui-table-inbox ui-table-alpha">
                <thead>
                    <tr>
                        <th style="width: 300px;">
                            拍品信息
                        </th>
                        <th>
                            竞拍时间
                        </th>
                        <th>
                            价格（金币）
                        </th>
                        <th>
                            重置秒数
                        </th>
                        <th>
                            出价信息
                        </th>
                        <th>
                            开拍日期
                        </th>
                        <th>
                            状 态
                        </th>
                        <th>
                            操 作
                        </th>
                    </tr>
                </thead>
                @Model.Auctions.Each(@<tbody>
                    <tr class="item-header">
                        <td colspan="1" class="text-align-left">
                            <span>#@(item.Item.Id)-@(item.Item.ItemId)</span> <span>等级：@(item.Item.Level)</span>
                        </td>
                        <td colspan="6" style="text-align: right;">
                            @if (item.Item.Reservation)
                            {
                                <a href="javascript:void(0);" class="auction-item-extra-option" title="该拍品需提前预约，预约成功的用户才可参与竞购！">
                                    <i class="fa fa-check"></i>&nbsp;预约竞购</a>
                            }
                            @if (item.Item.DiffBuy)
                            {
                                <a href="javascript:void(0);" class="auction-item-extra-option" title="@(item.Item.AuctionDiffBuyLimitText())">
                                    <i class="fa fa-check"></i>&nbsp;充许补差购买</a>
                            }
                            @if (item.Item.FreeBid)
                            {
                                <a href="javascript:void(0);" class="auction-item-extra-option"  title="@(item.Item.AuctionFreeBidLimitText())">
                                    <i class="fa fa-check"></i>&nbsp;充许使用免费拍币</a>
                            }
                            @if (item.Item.AlternateInterval != 0)
                            {
                                <a href="javascript:void(0);" class="auction-item-extra-option" title="该拍品将会在价格达到@(item.Item.AlternatePrice.ToString("N"))元后，自动调整重置秒数为@(item.Item.AlternateInterval)！">
                                    <i class="fa fa-check"></i>&nbsp;动态调整重置秒数</a>
                            }
                            @if (item.Item.IsZero)
                            {
                                <a href="javascript:void(0);" class="auction-item-extra-option" title="该拍品为0元竞购拍品！">
                                    <i class="fa fa-check"></i>&nbsp;0元竞购</a>
                            }
                            @if (item.Item.IsAuto)
                            {
                                <a href="javascript:void(0);" class="auction-item-extra-option" title="该拍品将会在用户成功竞拍后，自动生成一个新的拍品！">
                                    <i class="fa fa-check"></i>&nbsp;自动补货</a>
                            }
                        </td>
                        <td>
                            dd
                        </td>
                    </tr>
                    <tr>
                        <td title="@(item.Item.Name)">
                            <div class="media">
                                <a class="pull-left" href="@(string.Format("{0}/{1}.html", WebSite.Item, item.Item.Id))" target="_blank">
                                    <img class="media-object"  src="@item.Item.Picture(ProductItemImageSize.XS)" alt="@(item.Item.Name)" />
                                </a>
                                <div class="media-body">
                                    <h5 class="media-heading">
                                        <span id="item-name-@(item.Item.Id)">@(item.Item.Name)</span>
                                    </h5>
                                    <div>
                                        @foreach (var o in item.Item.PropTexts.OrderBy(o => o.Length))
                                        {
                                            <span>@o</span>
                                            <br />
                                        }
                                    </div>
                                </div>
                            </div>
                        </td>
                        <td>
                            @(item.Item.StartTime)<br />
                            --<br />@(item.Item.StopTime)
                        </td>
                        <td>
                            @(item.Item.Price)
                        </td>
                        <td>@(item.Item.Interval)
                        </td>
                        <td>
                            @if (item.Item.UserId == 0)
                            {
                                <span>等待出价</span>
                            }
                            else
                            {
                                <span>￥：@(item.Item.CurrentPrice.ToString("N"))</span><br />
                                <span title="@(item.Item.UserName)">@(item.Item.UserName)</span>
                            }
                        </td>
                        <td>
                            <span>@(item.Item.OnlineDate.ToString("yyyy-MM-dd"))</span>
                        </td>
                        <td>
                            @(item.Item.StatusText)
                        </td>
                        <td>
                            <a title="更新拍品" href="/auction/edit/@(item.Item.Id)" class="auction-item-extra-action" target="_blank">
                                <i class="fa fa-pencil"></i>&nbsp;编 辑</a><br />
                            <a title="克隆拍品" href="/auction/clone/@(item.Item.Id)" class="auction-item-extra-action" target="_blank">
                                <i class="fa fa-copy"></i>&nbsp;克 隆</a><br />
                        </td>
                    </tr>
                    <tr class="item-footer">
                        <td colspan="8">
                        </td>
                    </tr>
                </tbody>)
            </table>
        </div>
    </div>
</div>
@section css
{
    <link rel="stylesheet" type="text/css" href="http://todc.github.io/todc-datepicker/assets/css/todc-datepicker.css" />
    <style type="text/css">
        a.auction-item-extra-option { color: #777; text-decoration: none; margin-right: 5px; }
        a.auction-item-extra-option:hover { color: #444; text-decoration: none; }
        a.auction-item-extra-action { text-decoration: none; color: #f40; }
        a.auction-item-extra-action:hover { text-decoration: none; }
    </style>
}
@section js{
    <script type="text/javascript">


        $(function () {
            $('select').select2();
            $('.datepicker').datepicker();
            $('[data-rel="popover"]').popover();
            $('#modal').on('hidden.bs.modal', function () {
                $(this).empty().removeData('bs.modal');
            });
        });

    </script>
}
